package com.nkzy.service.impl;

import com.nkzy.mapper.UserMapper;
import com.nkzy.pojo.User;
import com.nkzy.service.UserService;
import com.nkzy.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
* 这个类就是Userservice接口的实现类
* 实现类要完成接口中方法的编写
* 在实现类中,要通过注解实现@Service实现IoC
* IoC:控制反转,把创建对象的权利交由Spring框架
*
* */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User findUserByName(String username) {
       User user=userMapper.selectUserByName(username);
        return user;
    }

    @Override
    public void register(String username, String password) {
        //1.对密码进行加密处理,MD5
        String md5String = Md5Util.getMD5String(password);
        //2.注册
        userMapper.insert(username,md5String);

    }
}
